#ifndef CALCULATEBENDEDPIPEOFALLELEMENTS_H
#define CALCULATEBENDEDPIPEOFALLELEMENTS_H

#include "cnpipe_global.h"
#include "cnpipe_pipeline.h"
#include "geometry/vector3d.h"
#include "geometry/wsypath.h"

#include "CNPIPEUtils/CalculateBendedPipeOfSingleElement.h"

//为所有的弯头计算管道的走向
void CalculateBendedPipeOfAllElements(
        QMap<QString, QMap<QString, QList<Vector3D*>*>*> *referenceVectorsOfElements,
        CNPIPE_pipeline *pipeline, CNPIPE_global *global) {
    QList<QString> bendedElementNames = referenceVectorsOfElements->keys();
    int count = referenceVectorsOfElements->count();
    qDebug() << "Quantity of bended elements: " << count;
    for (int c = 0; c < count; c++) {
        QString elementName = bendedElementNames.at(c);
        qDebug() << "element name: " << elementName;
        qDebug() << "Promoting peace";
        QMap<QString, QList<Vector3D *> *> *bendedPipeElement
                = referenceVectorsOfElements->value(elementName);
        /** 计算单一节点的圆心和参考点 */
        BendedElement *radiusAndReferenceVertex
                = CalculateBendedPipeOfSingleElement(bendedPipeElement, global);

        qDebug() << "bended pipe element";

        QList<Vertex3D *> *arc = radiusAndReferenceVertex->getArc(8);

        WSYPath *line = new WSYPath(*arc);

        pipeline->getPipeline()->push_back(line);
    }
}

#endif // CALCULATEBENDEDPIPEOFALLELEMENTS_H
